package project.service;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import project.mapper.MajorMapper;
import project.pojo.Major;
import project.util.SqlSessionFactoryUtils;

import java.util.List;

public class MajorService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
    public List<Major> selectMajorsByDepartmentName(String departmentName){
        SqlSession sqlSession = sqlSessionFactory.openSession();
        MajorMapper majorMapper = sqlSession.getMapper(MajorMapper.class);
        List<Major> majorList = majorMapper.selectMajorsByDepartmentName(departmentName);
        sqlSession.close();
        return majorList;
    }
}
